using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using MonoTouch.Foundation;
using MonoTouch.UIKit;
using CoachingOrganizer.Logic.Models.Common;
using CoachingOrganizer.iOS.Helpers;

namespace CoachingOrganizer.iOS.Controllers
{
    public partial class PeriodViewController : UIViewController
    {
        private readonly PeriodModel _model;

        public PeriodViewController(PeriodModel model)
            : base("PeriodView", NSBundle.MainBundle)
        {
            _model = model;
        }

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            StartDateView.Date = _model.StartDate;
            FinishDateView.Date = _model.FinishDate;
        }

        partial void ShowPeriodDetails(NSObject sender)
        {
            PeriodDetailsViewController detailsController = new PeriodDetailsViewController(_model);
            ParentViewController.PresentViewController(detailsController, true, null);
        }

        partial void ChangeStartDate(NSObject sender)
        {
            _model.StartDate = StartDateView.Date;
        }

        partial void ChangeFinishDate(NSObject sender)
        {
            _model.FinishDate = FinishDateView.Date;
        }
    }
}